package com.may.wlrj.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.may.wlrj.util.MQTTUtil;

@Controller
public class MqttController {
	private Logger log = Logger.getLogger(MqttController.class);
	
    @RequestMapping(value = "/mqttSend", method = RequestMethod.POST,produces="text/html;charset=UTF-8;")    
    public @ResponseBody String testSend(@RequestBody String objnode,HttpServletRequest request, HttpServletResponse response) {
        try {
            String topic = "hello";
            String content = "test xxxxx";
            MQTTUtil.publish(topic,content);
        } catch (Exception ex) {
            ex.printStackTrace();
            log.error("发送失败", ex);
        }

        return "发送成功";
    }
}
